package io.xccit.pojo.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.xccit.pojo.product.Product;
import io.xccit.pojo.shopcart.Cart;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author CH_ywx
 * @date 2023-09-18
 * @description 购物车Vo
 */
@Data
@ApiModel("购物车VO")
@JsonIgnoreProperties(ignoreUnknown = true)
@NoArgsConstructor
public class CartVO {
    @ApiModelProperty("购物车ID")
    private Integer id;
    @ApiModelProperty("商品ID")
    private Integer productId;
    @ApiModelProperty("商品名")
    private String productName;
    @ApiModelProperty("商品图片地址")
    private String productImage;
    @ApiModelProperty("商品价格")
    private Double price;
    @ApiModelProperty("购买数量")
    private Integer num;
    @ApiModelProperty("最大可购买数量")
    private Integer maxNum;
    @ApiModelProperty("是否选中,默认否")
    private Boolean check = false;

    public CartVO(Product product, Cart cart){
        this.id = cart.getId();
        this.productId = product.getProductId();
        this.productName = product.getProductName();
        this.productImage = product.getProductPicture();
        this.price = product.getProductSellingPrice();
        this.num = cart.getNum();
        this.maxNum = product.getProductNum();
        this.check = false;
    }
}
